use "$project_path/data/4_regdata/regdata", clear

** Appendix Figure C.2(a) 
rddensity runvar if subsample_democ==1
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if subsample_democ==1, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_C2a.pdf", as(pdf) name("Graph") replace

** Appendix Figure C.2(b) 
rddensity runvar if subsample_autoc==1
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if subsample_autoc==1, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_C2b.pdf", as(pdf) name("Graph") replace

** Appendix Figure C.2(c) 
rddensity runvar if subsample_freefair==1
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if subsample_freefair==1, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_C2c.pdf", as(pdf) name("Graph") replace

** Appendix Figure C.2(d) 
rddensity runvar if subsample_not_freefair==1
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if subsample_not_freefair==1, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_C2d.pdf", as(pdf) name("Graph") replace

** Appendix Figure C.2(e) 
rddensity runvar if subsample_large_parl==1
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if subsample_large_parl==1, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_C2e.pdf", as(pdf) name("Graph") replace

** Appendix Figure C.2(f) 
rddensity runvar if subsample_small_parl==1
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if subsample_small_parl==1, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_C2f.pdf", as(pdf) name("Graph") replace
